import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:github_client_app/common/Global.dart';
import 'package:github_client_app/l10n/localization_intl.dart';
import 'package:provider/provider.dart';

class HomeRoute extends StatefulWidget {

  @override
  State createState() {
    return _HomeRouteState();
  }
}

class _HomeRouteState extends State<HomeRoute> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(DemoLocalizations.of(context).home),
      ),
      body: _buildBody(), // 构建主页面
//      drawer: MyDrawer(), //抽屉菜单
    );
  }

  Widget _buildBody() {
    UserModel userModel = Provider.of<UserModel>(context);
    if (!userModel.isLogin) {
      //用户未登录，显示登录按钮
      return Center(
        child: RaisedButton(
          child: Text(DemoLocalizations.of(context).login),
          onPressed: () {
            Navigator.of(context).pushNamed("login");
          },
        ),
      );
    } else {
      //已登录，则展示项目列表
      return Text("a");
    }
  }
}